<script setup lang="ts">
/**
 * @see {@link https://vuejs.org/api/sfc-script-setup.html#defineoptions}
 */
defineOptions({
  name: "TMallOrder",
  inheritAttrs: false,
});
import {
	getDyOrderPage,
} from "@/api/dyOrder";

import { DyOrderQuery, DyOrderPageVO } from "@/api/dyOrder/types";

const queryFormRef = ref(ElForm); // 查询表单

const loading = ref(false);
const ids = ref([]);
const total = ref(0);
const monthValue = ref('')

const queryParams = reactive<DyOrderQuery>({
  pageNum: 1,
  pageSize: 10,
});
const dyOrderList = ref<DyOrderPageVO[]>();



/**
 * 查询
 */
function handleQuery() {
  queryParams.billMonth = monthValue.value
  loading.value = true;
  getDyOrderPage(queryParams)
    .then(({ data }) => {
		dyOrderList.value = data.list;
      total.value = data.total;
    })
    .finally(() => {
      loading.value = false;
    });
}

/** 重置查询 */
function resetQuery() {
  queryParams.pageNum = 1;
  handleQuery();
}

onMounted(() => {
  let now = new Date()
  let month = now.getMonth()
  if (month < 9){
    monthValue.value = now.getFullYear() + '0' + (now.getMonth() + 1) + ''
  }	else {
    monthValue.value = now.getFullYear() + '' + (now.getMonth() + 1) + ''
  }
  handleQuery(); // 初始化标准账单配置列表数据
});
</script>

<template>
  <div class="app-container">
    <el-row :gutter="20">

      <el-col>
        <div class="search-container">
          <el-form ref="queryFormRef" :model="queryParams" :inline="true">
            <el-form-item label="订单月份">
              <el-date-picker
                      v-model="monthValue"
                      type="month"
                      value-format="YYYYMM"
                      :editable="false"
                      :clearable="false"
                      placeholder="选择月份"
              />
            </el-form-item>
            <el-form-item label="主订单编号" prop="keywords">
              <el-input
                v-model="queryParams.keywords"
                placeholder="请输入主订单编号"
                clearable
                style="width: 200px"
                @keyup.enter="handleQuery"
              />
            </el-form-item>

            <el-form-item>
              <el-button type="primary" @click="resetQuery"
                ><i-ep-search />搜索</el-button
              >
              <el-button @click="resetQuery">
                <i-ep-refresh />
                重置</el-button
              >
            </el-form-item>
          </el-form>
        </div>

        <el-card shadow="never">

          <el-table
						size="small"
						:height="dyOrderList && dyOrderList.length > 0 ? 650 : 100"
            v-loading="loading"
            :data="dyOrderList"
			border
          >
            <el-table-column
              label="主订单编号"
              align="center" show-overflow-tooltip
              prop="mainOrderNo"
              width="200"
            />
            <el-table-column
              label="子订单编号"
			  width="200"
              align="center" show-overflow-tooltip
              prop="subOrderNo"
            />
            <el-table-column
              label="选购商品"
              width="120"
              align="center" show-overflow-tooltip
              prop="buyProduct"
            />

            <el-table-column
              label="商品规格"
              width="100"
              align="center" show-overflow-tooltip
              prop="specifications"
            />

            <el-table-column
              label="商品数量"
              width="120"
              align="center" show-overflow-tooltip
              prop="quantity"
            />
            <el-table-column
              label="商品ID"
              align="center" show-overflow-tooltip
              prop="productId"
              width="120"
            />
            <el-table-column
              label="商家编码"
              align="center" show-overflow-tooltip
              prop="businessCode"
              width="180"
            ></el-table-column>
            <el-table-column
              label="商品单价"
              align="center" show-overflow-tooltip
              prop="productPrice"
              width="180"
            ></el-table-column>
            <el-table-column
              label="订单应付金额"
              align="center" show-overflow-tooltip
              prop="payAmount"
              width="180"
            ></el-table-column>
            <el-table-column
              label="运费"
              align="center" show-overflow-tooltip
              prop="transportFee"
              width="180"
            ></el-table-column>
            <el-table-column
              label="优惠总金额"
              align="center" show-overflow-tooltip
              prop="preferentialAmout"
              width="180"
            ></el-table-column>
            <el-table-column
              label="平台优惠"
              align="center" show-overflow-tooltip
              prop="preformPreferential"
              width="180"
            ></el-table-column>
            <el-table-column
              label="商家优惠"
              align="center" show-overflow-tooltip
              prop="businessPreferential"
              width="180"
            ></el-table-column>
            <el-table-column
              label="达人优惠"
              align="center" show-overflow-tooltip
              prop="drPreferential"
              width="180"
            ></el-table-column>
            <el-table-column
              label="商家改价"
              align="center" show-overflow-tooltip
              prop="modifyPrice"
              width="180"
            ></el-table-column>
            <el-table-column
              label="支付优惠"
              align="center" show-overflow-tooltip
              prop="payPreferential"
              width="180"
            ></el-table-column>
            <el-table-column
              label="红包抵扣"
              align="center" show-overflow-tooltip
              prop="deduction"
              width="180"
            ></el-table-column>
            <el-table-column
              label="支付方式"
              align="center" show-overflow-tooltip
              prop="payType"
              width="180"
            ></el-table-column>
            <el-table-column
              label="手续费"
              align="center" show-overflow-tooltip
              prop="handlingFee"
              width="180"
            ></el-table-column>
            <el-table-column
              label="收件人"
              align="center" show-overflow-tooltip
              prop="receiver"
              width="180"
            ></el-table-column>
            <el-table-column
              label="收件人手机号"
              align="center" show-overflow-tooltip
              prop="receiverPhone"
              width="180"
            ></el-table-column>
            <el-table-column
              label="省"
              align="center" show-overflow-tooltip
              prop="provice"
              width="180"
            ></el-table-column>
            <el-table-column
              label="市"
              align="center" show-overflow-tooltip
              prop="city"
              width="180"
            ></el-table-column>
            <el-table-column
              label="区"
              align="center" show-overflow-tooltip
              prop="area"
              width="180"
            ></el-table-column>
            <el-table-column
              label="街道"
              align="center" show-overflow-tooltip
              prop="street"
              width="180"
            ></el-table-column>
            <el-table-column
              label="详细地址"
              align="center" show-overflow-tooltip
              prop="address"
              width="180"
            ></el-table-column>
            <el-table-column
              label="是否修改过地址"
              align="center" show-overflow-tooltip
              prop="modifyAddress"
              width="180"
            ></el-table-column>
            <el-table-column
              label="买家留言"
              align="center" show-overflow-tooltip
              prop="buyerRemark"
              width="180"
            ></el-table-column>
            <el-table-column
              label="订单提交时间"
              align="center" show-overflow-tooltip
              prop="orderTime"
              width="180"
            ></el-table-column>
            <el-table-column
              label="旗帜颜色"
              align="center" show-overflow-tooltip
              prop="flagColor"
              width="180"
            ></el-table-column>
            <el-table-column
              label="商家备注"
              align="center" show-overflow-tooltip
              prop="sellerRemark"
              width="180"
            ></el-table-column>
            <el-table-column
              label="订单完成时间"
              align="center" show-overflow-tooltip
              prop="orderFinishTime"
              width="180"
            ></el-table-column>
            <el-table-column
              label="APP渠道"
              align="center" show-overflow-tooltip
              prop="appChannel"
              width="180"
            ></el-table-column>
            <el-table-column
              label="流量来源"
              align="center" show-overflow-tooltip
              prop="source"
              width="180"
            ></el-table-column>
            <el-table-column
              label="订单状态"
              align="center" show-overflow-tooltip
              prop="orderStatus"
              width="180"
            ></el-table-column>
            <el-table-column
              label="承诺发货时间"
              align="center" show-overflow-tooltip
              prop="promiseSendTime"
              width="180"
            ></el-table-column>
            <el-table-column
              label="订单类型"
              align="center" show-overflow-tooltip
              prop="orderType"
              width="180"
            ></el-table-column>
            <el-table-column
              label="鲁班落地页ID"
              align="center" show-overflow-tooltip
              prop="lbldyId"
              width="180"
            ></el-table-column>
            <el-table-column
              label="达人ID"
              align="center" show-overflow-tooltip
              prop="drId"
              width="180"
            ></el-table-column>
            <el-table-column
              label="达人昵称"
              align="center" show-overflow-tooltip
              prop="drNickName"
              width="180"
            ></el-table-column>
            <el-table-column
              label="所属门店ID"
              align="center" show-overflow-tooltip
              prop="ownerShopId"
              width="180"
            ></el-table-column>
            <el-table-column
              label="售后状态"
              align="center" show-overflow-tooltip
              prop="serviceStatus"
              width="180"
            ></el-table-column>
            <el-table-column
              label="取消原因"
              align="center" show-overflow-tooltip
              prop="rejectReason"
              width="180"
            ></el-table-column>
            <el-table-column
              label="预约发货时间"
              align="center" show-overflow-tooltip
              prop="previousSendTime"
              width="180"
            ></el-table-column>
            <el-table-column
              label="仓库ID"
              align="center" show-overflow-tooltip
              prop="storeId"
              width="180"
            ></el-table-column>
            <el-table-column
              label="仓库名称"
              align="center" show-overflow-tooltip
              prop="storeName"
              width="180"
            ></el-table-column>
            <el-table-column
              label="是否安心购"
              align="center" show-overflow-tooltip
              prop="peaceBuy"
              width="180"
            ></el-table-column>
            <el-table-column
              label="广告渠道"
              align="center" show-overflow-tooltip
              prop="adviceChannel"
              width="180"
            ></el-table-column>
            <el-table-column
              label="流量类型"
              align="center" show-overflow-tooltip
              prop="flowType"
              width="180"
            ></el-table-column>
            <el-table-column
              label="流量体裁"
              align="center" show-overflow-tooltip
              prop="flowApp"
              width="180"
            ></el-table-column>
            <el-table-column
              label="流量渠道"
              align="center" show-overflow-tooltip
              prop="flowChannel"
              width="180"
            ></el-table-column>
            <el-table-column
              label="发货主体"
              align="center" show-overflow-tooltip
              prop="senderCompany"
              width="180"
            ></el-table-column>
            <el-table-column
              label="发货主体明细"
              align="center" show-overflow-tooltip
              prop="senderCompanyDetail"
              width="180"
            ></el-table-column>
            <el-table-column
              label="发货时间"
              align="center" show-overflow-tooltip
              prop="sendTime"
              width="180"
            ></el-table-column>
            <el-table-column
              label="降价类优惠"
              align="center" show-overflow-tooltip
              prop="cutPrice"
              width="180"
            ></el-table-column>
            <el-table-column
              label="平台实际承担优惠金额"
              align="center" show-overflow-tooltip
              prop="preformPreferentialPrice"
              width="180"
            ></el-table-column>
            <el-table-column
              label="商家实际承担优惠金额"
              align="center" show-overflow-tooltip
              prop="sellerPreferentialPrice"
              width="180"
            ></el-table-column>
            <el-table-column
              label="达人实际承担优惠金额"
              align="center" show-overflow-tooltip
              prop="drPreferentialPrice"
              width="180"
            ></el-table-column>
            <el-table-column
              label="预计送达时间"
              align="center" show-overflow-tooltip
              prop="previousReceiveTime"
              width="180"
            ></el-table-column>
            <el-table-column
              label="是否平台仓自流转"
              align="center" show-overflow-tooltip
              prop="preformFlow"
              width="180"
            ></el-table-column>
            <el-table-column
              label="车型"
              align="center" show-overflow-tooltip
              prop="vehicle"
              width="180"
            ></el-table-column>
          </el-table>
          <pagination
            v-if="total > 0"
            v-model:total="total"
            v-model:page="queryParams.pageNum"
            v-model:limit="queryParams.pageSize"
            @pagination="handleQuery"
          />
        </el-card>
      </el-col>
    </el-row>

  </div>
</template>
